<template>
  <div id="detail">
    <detail-nav-bar class="detail-nav"></detail-nav-bar>
    <detail-swiper :topImages="topImages"></detail-swiper>
    <detail-base-info :goods="goods"></detail-base-info>
    <detail-shop-info :shops="shops"></detail-shop-info>
  </div>
</template>s

<script>
  import DetailNavBar from "./childComps/DetailNavBar";
  import DetailSwiper from "./childComps/DetailSwiper";
  import DetailBaseInfo from "./childComps/DetailBaseInfo";
  import DetailShopInfo from "./childComps/DetailShopInfo";

  import {getDetail,Goods} from "../../network/detail";

  export default {
    name: "Detail",
    components: {
      DetailNavBar,
      DetailSwiper,
      DetailBaseInfo,
      DetailShopInfo
    },
    data() {
      return {
        iid:'',
        topImages:[],
        goods:{},
        shops:{}
      }
    },
    created() {
      //保存传入的iid
      this.iid=this.$route.params.iid

      // 获取轮播图数据
      getDetail(this.iid).then(res=>{
        console.log(res)
        // 顶部轮播图数据
        const data=res.result
        this.topImages= data.itemInfo.topImages
        //获取商品信息数据
        this.goods=new Goods( data.itemInfo, data.columns, data.shopInfo.services)
        // 获取店铺信息
        this.shops=new Shop(data.shopInfo)
      })
    }
  }
</script>

<style scoped>

</style>
